
:root {
    --amily2-bg-color: #2C2C2C;
    --amily2-button-color: #4A4A4A;
    --amily2-text-color: #E0E0E0;
    --amily2-bg-image: url('https://cdn.jsdelivr.net/gh/Wx-2025/ST-Amily2-images@main/images2/guigubahuang_2024-09-27_11-20-00_v2.png');
    --amily2-bg-opacity: 0.85; 
}

#amily2_drawer_content .flex-container {
    width: 100%; height: 100%; display: flex; flex-direction: column;
}

#amily2_chat_optimiser {
    position: relative; 
    background: var(--amily2-bg-image) no-repeat center center !important;
    background-size: cover !important;
    z-index: 0;
    width: 100%;
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 15px 20px;
    box-sizing: border-box;
    color: var(--amily2-text-color) !important;
}

#amily2_chat_optimiser::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--amily2-bg-color);
    opacity: var(--amily2-bg-opacity);
    z-index: -1;
    pointer-events: none; 
}

#amily2_chat_optimiser #auth_panel {
    position: relative;
    background: transparent !important;
    z-index: 0;
    padding: 20px; 
    border-radius: 12px; 
    margin-bottom: 20px;
    backdrop-filter: blur(5px);
}
#auth_panel .auth-header { text-align: center; margin-bottom: 20px; }
#auth_panel .auth-title { 
    font-size: 1.8rem; 
    background: linear-gradient(to right, #ff9800, #ff5722); 
    -webkit-background-clip: text; 
    background-clip: text; 
    color: transparent; 
}
#auth_panel .auth-subtitle { color: var(--amily2-text-color); margin-top: 5px; }
#auth_panel .auth-code-input { display: flex; margin-bottom: 15px; }
#auth_panel #amily2_auth_code { 
    flex: 1; padding: 10px; border-radius: 8px 0 0 8px; 
    border: 1px solid #7e57c2; 
    background: rgba(0,0,0,0.3); 
    color: var(--amily2-text-color); 
}
#auth_panel #auth_submit { 
    padding: 10px 15px; border: none; 
    background: var(--amily2-button-color); 
    color: var(--amily2-text-color); 
    border-radius: 0 8px 8px 0; 
    cursor: pointer; 
}
#auth_panel .auth-footer { text-align: center; font-size: 0.8em; color: var(--amily2-text-color); }

.auth-status { padding: 10px; border-radius: 8px; text-align: center; margin-top: 15px; }
.auth-status.valid { background-color: rgba(76, 175, 80, 0.2); border: 1px solid #4CAF50; }
.auth-status.expired { background-color: rgba(244, 67, 54, 0.2); border: 1px solid #f44336; }

#amily2_chat_optimiser .amily2_settings_block {
    position: relative;
    background: transparent !important;
    z-index: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    margin: 0;
    border-radius: 8px;
    backdrop-filter: blur(3px);
}

.amily2_settings_block label {
    color: var(--amily2-text-color) !important;
    margin-right: 10px;
    font-weight: bold;
}

.amily2_settings_block input[type="color"] {
    width: 50px;
    height: 30px;
    border: none;
    border-radius: 4px;
    margin-right: 15px;
    cursor: pointer;
}

.amily2_settings_block .menu_button {
    margin-top: 10px;
    background: var(--amily2-button-color) !important;
    color: var(--amily2-text-color) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.amily2_settings_block .menu_button:hover {
    background: rgba(74, 74, 74, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

#amily2_chat_optimiser .main-toggle { margin: 0; }
#amily2_chat_optimiser .main-toggle label { font-size: 1.2em; color: var(--amily2-text-color) !important; }

#amily2_chat_optimiser .update-section {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 50px;
}

#amily2_update_button { 
    background: var(--amily2-button-color) !important; 
    border: 1px solid rgba(255,255,255,0.2); 
    padding: 5px 8px; 
    color: var(--amily2-text-color) !important;
}
#amily2_update_button:hover { 
    background: rgba(74, 74, 74, 0.8) !important; 
}

.update-indicator {
    position: absolute; top: -3px; right: -3px; width: 10px; height: 10px;
    background-color: #ff4d4d; border-radius: 50%; border: 1px solid var(--amily2-bg-color);
}

hr.header-divider { 
    border: none; 
    border-top: 1px solid rgba(255,255,255,0.1); 
    margin: 0 0 10px 0; 
}

#amily2_chat_optimiser .settings-group {
    position: relative;
    background: transparent !important;
    z-index: 0;
    border: 1px solid rgba(255, 255, 255, 0.2); 
    border-radius: 8px;
    padding: 8px 12px; 
    margin: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 5px;
    backdrop-filter: blur(3px);
}

.settings-group legend {
    font-size: 1.1em; 
    font-weight: bold; 
    color: var(--amily2-text-color) !important; 
    padding: 0 10px; 
    margin-left: 10px;
}

.settings-group legend > i { 
    margin-right: 8px; 
    color: #7e57c2; 
}

.settings-group legend > i.fa-palette {
    color: #ff9800;
}


#amily2_chat_optimiser .color-controls-container {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 15px !important;
    flex-wrap: wrap;
}

#amily2_chat_optimiser .color-picker-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    flex-wrap: wrap;
}

#amily2_chat_optimiser .color-picker-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* === 可变透明度容器背景 === */
#amily2_chat_optimiser .settings-group::before,
#amily2_chat_optimiser .amily2_settings_block::before,
#amily2_chat_optimiser #auth_panel::before,
#amily2_chat_optimiser .extension_block::before,
#amily2_chat_optimiser .plugin-features::before,
#amily2_chat_optimiser .amily2_extension_frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--amily2-bg-color);
    opacity: var(--amily2-bg-opacity);
    z-index: -1;
    pointer-events: none;
}

#amily2_chat_optimiser .settings-group::before,
#amily2_chat_optimiser .amily2_settings_block::before,
#amily2_chat_optimiser .extension_block::before,
#amily2_chat_optimiser .plugin-features::before,
#amily2_chat_optimiser .amily2_extension_frame::before {
    border-radius: 8px;
}

#amily2_chat_optimiser #auth_panel::before {
    border-radius: 12px;
}

#amily2_chat_optimiser .settings-group {
    margin-bottom: 5px;
}

#amily2_chat_optimiser .settings-group:last-child {
    margin-bottom: 0;
}

/* === 扩展卡片和面板样式 === */
#amily2_chat_optimiser .extension_settings {
    background: var(--amily2-bg-color) !important;
    color: var(--amily2-text-color) !important;
}

#amily2_chat_optimiser #extensions_settings2, 
#amily2_chat_optimiser .extension_block,
#amily2_chat_optimiser .plugin-features,
#amily2_chat_optimiser .amily2_extension_frame {
    position: relative;
    background: transparent !important;
    z-index: 0;
    color: var(--amily2-text-color) !important;
}

/* === 按钮统一样式 (已限定作用域) === */
#amily2_chat_optimiser .amily2_extension_frame .menu_button,
#amily2_chat_optimiser .extension_block .menu_button,
#amily2_chat_optimiser #amily2_drawer_content .menu_button {
    background: var(--amily2-button-color) !important;
    color: var(--amily2-text-color) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#amily2_chat_optimiser .amily2_extension_frame .menu_button:hover,
#amily2_chat_optimiser .extension_block .menu_button:hover,
#amily2_chat_optimiser #amily2_drawer_content .menu_button:hover {
    background: rgba(74, 74, 74, 0.8) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* === 输入框样式 (已限定作用域) === */
#amily2_chat_optimiser .amily2_extension_frame input,
#amily2_chat_optimiser .amily2_extension_frame textarea,
#amily2_chat_optimiser .amily2_extension_frame select,
#amily2_chat_optimiser #amily2_drawer_content input,
#amily2_chat_optimiser #amily2_drawer_content textarea,
#amily2_chat_optimiser #amily2_drawer_content select {
    background: rgba(74, 74, 74, 0.6) !important;
    color: var(--amily2-text-color) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* === 抽屉容器样式 === */
#amily2_main_drawer {
    /* 顶栏的父容器应保持透明，不应有背景或边框 */
    background: transparent !important;
    border: none !important;
}

#amily2_drawer_content {
    /* 父容器应保持透明，让子元素的背景得以显示 */
    background: transparent !important;
    color: var(--amily2-text-color) !important;
}

/* === 开关样式 === */
#amily2_chat_optimiser .toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}
.toggle-switch input { 
    opacity: 0; 
    width: 0; 
    height: 0; 
}
.toggle-switch .slider {
    position: absolute; 
    cursor: pointer; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0;
    background-color: var(--amily2-bg-color); 
    border-radius: 26px; 
    transition: .4s;
    border: 1px solid #555;
}
.toggle-switch .slider:before {
    position: absolute; 
    content: ""; 
    height: 20px; 
    width: 20px; 
    left: 2px;
    bottom: 2px;
    background-color: var(--amily2-text-color); 
    border-radius: 50%; 
    transition: .4s;
}
.toggle-switch input:checked + .slider {
    background: linear-gradient(to right, #7e57c2, #5e35b1);
    box-shadow: 0 0 8px rgba(126, 87, 194, 0.7);
}
.toggle-switch input:checked + .slider:before { 
    transform: translateX(24px); 
}

/* === 单选按钮组样式 === */
#amily2_chat_optimiser .radio-toggle-group {
    display: flex; 
    border: 1px solid #555; 
    border-radius: 8px; 
    overflow: hidden;
}
.radio-toggle-group input[type="radio"] { 
    display: none; 
}
.radio-toggle-group label {
    flex: 1; 
    text-align: center; 
    padding: 8px 10px; 
    cursor: pointer;
    background-color: var(--amily2-bg-color); 
    color: var(--amily2-text-color); 
    transition: all 0.3s ease;
    border-left: 1px solid #555; 
    margin: 0 !important;
}
.radio-toggle-group label:first-of-type { 
    border-left: none; 
}
.radio-toggle-group input[type="radio"]:checked + label {
    background-color: #7e57c2; 
    color: var(--amily2-text-color); 
    font-weight: bold;
}

/* === 控制对容器样式 === */
#amily2_chat_optimiser .control-pair-container {
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    gap: 10px;
}

.control-pair-container .amily2_settings_block {
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 5px;
}
.control-pair-container .amily2_settings_block label:first-of-type { 
    margin-bottom: 0; 
}

#amily2_chat_optimiser .amily2_settings_block { display: flex; flex-direction: column; gap: 8px; }
.amily2_settings_block label { 
    font-weight: bold; 
    color: var(--amily2-text-color) !important; 
}
.amily2_settings_block .notes {
    font-size: 0.8em; 
    color: var(--amily2-text-color); 
    opacity: 0.9; 
    font-style: italic;
    align-self: flex-start; 
    padding-left: 5px;
}
.control-pair-container .amily2_settings_block .notes { 
    align-self: center; 
}
.label-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === Lore配置样式 === */
#amily2_chat_optimiser .amily2_lore_config_wrapper {
    display: flex;
    gap: 15px;
}

.amily2_lore_config_section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.amily2_vertical_divider {
    width: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    align-self: stretch;
}

#amily2_save_lore_settings {
    width: 100%;
    background: linear-gradient(135deg, #7e57c2, #5e35b1) !important;
    border: 1px solid #4527a0 !important;
    color: var(--amily2-text-color) !important;
}
#amily2_save_lore_settings:hover {
    background: linear-gradient(135deg, #5e35b1, #7e57c2) !important;
    box-shadow: 0 0 8px rgba(126, 87, 194, 0.6);
}

#amily2_lore_save_status {
    color: #66bb6a;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    padding-top: 5px;
}

/* === 通用样式 === */
#amily2_chat_optimiser hr { 
    border: none; 
    border-top: 1px solid rgba(255,255,255,0.1); 
    margin: 0; 
}
#amily2_chat_optimiser .text_pole, #amily2_chat_optimiser select { 
    width: 100%; 
    box-sizing: border-box; 
}

#amily2_chat_optimiser .button-pair { 
    flex-direction: row; 
    justify-content: space-between; 
    gap: 15px; 
}
.button-pair .menu_button { 
    flex-grow: 1; 
}
#amily2_chat_optimiser .flex-container .primary { 
    background-color: #2196F3 !important; 
}
#amily2_chat_optimiser .flex-container .accent { 
    background-color: #FF5722 !important; 
}

/* === 抽屉图标状态 === */
#amily2_drawer_icon.closedIcon { opacity: 0.5; }
#amily2_drawer_icon.openIcon { opacity: 1; }
#amily2_drawer_icon.interactable:hover { opacity: 1; }

/* 强制保护顶栏图标不受主题颜色影响 */
#amily2_drawer_icon {
    background: none !important;
    color: inherit !important;
}

/* === 特殊功能开关样式 === */
#amily2_optimization_enabled:checked + .slider {
    background: linear-gradient(to right, #28a745, #20c997) !important;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.7);
}

#amily2_summarization_enabled:checked + .slider {
    background: linear-gradient(to right, #007bff, #17a2b8) !important;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.7);
}

/* === 位置选择按钮样式 === */
#amily2_icon_location_topbar:checked + label {
    background: linear-gradient(135deg, #0d6efd, #0dcaf0) !important;
    color: white !important;
    font-weight: bold;
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.5), 0 0 12px rgba(13, 110, 253, 0.6);
    transform: translateY(-2px); 
    border-color: #0dcaf0;
}

#amily2_icon_location_extensions:checked + label {
    background: linear-gradient(135deg, #ffc107, #fd7e14) !important;
    color: #492000 !important;
    font-weight: bold;
    text-shadow: 0 0 1px rgba(255,255,255,0.7);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.6), 0 0 12px rgba(255, 193, 7, 0.6);
    transform: translateY(-2px); 
    border-color: #ffc107;
}

.radio-toggle-group label {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#amily2_mode_intercept:checked + label {
    background: linear-gradient(135deg, #00bfa5, #00acc1) !important; 
    color: white !important;
    text-shadow: 0 0 3px rgba(0,0,0,0.4);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.4), 0 0 10px rgba(0, 191, 165, 0.6);
    transform: translateY(-2px);
}

#amily2_mode_refresh:checked + label {
    background: linear-gradient(135deg, #3f51b5, #2196f3) !important;
    color: white !important;
    text-shadow: 0 0 3px rgba(0,0,0,0.4);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.4), 0 0 10px rgba(63, 81, 181, 0.6);
    transform: translateY(-2px);
}

/* === 特殊按钮样式 === */
#amily2_refresh_models {
    background: linear-gradient(to right, #2196F3, #1976D2) !important;
    border: 1px solid #1565C0 !important;
    transition: all 0.3s ease;
}
#amily2_refresh_models:hover {
    background: linear-gradient(to right, #1976D2, #2196F3) !important;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.7);
    transform: scale(1.03); 
}

#amily2_unified_restore_button.secondary {
    background: linear-gradient(to right, #ffb300, #fb8c00) !important;
    border: 1px solid #f57c00 !important;
    color: #4d2c00 !important;
    transition: all 0.3s ease;
}
#amily2_unified_restore_button.secondary:hover {
    background: linear-gradient(to right, #fb8c00, #ffb300) !important;
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.7);
    transform: scale(1.03);
}

/* === 头部动作组 === */
#amily2_chat_optimiser .header-actions-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* === 密室按钮 === */
#amily2_chat_optimiser .secret-chamber-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: bold;
    color: var(--amily2-text-color) !important;
    background-color: var(--amily2-bg-color) !important;
    border: 1px solid var(--border_color) !important;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.secret-chamber-button i {
    margin-right: 8px;
}

.secret-chamber-button:hover {
    background-color: var(--background_tertiary) !important;
    border-color: var(--text_color_half) !important;
    color: var(--primary_color) !important;
}

/* === 响应式按钮组 === */
#amily2_chat_optimiser .button-group {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .button-group {
        flex-direction: row;
        justify-content: space-between;
        gap: 3px;
        align-items: stretch;
    }
    
    .button-group .menu_button.wide_button {
        flex: 1;
        height: 50px;
        padding: 2px;
        text-align: center;
        line-height: 1.1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        font-size: clamp(8px, 2.5vw, 14px);
    }
    
    .button-group .menu_button.wide_button i {
        display: block;
        margin-bottom: 2px;
    }
}

@media (min-width: 769px) {
    .button-group {
        flex-direction: row;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .button-group .menu_button.wide_button {
        flex: 1;
        min-width: 0;
    }
}

/* === 面板可见性 === */
#amily2_chat_optimiser .amily2-panel-visible {
    display: flex !important;
    flex-direction: column;
    flex-grow: 1;
    gap: 15px;
}

#amily2_chat_optimiser .header-left-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
 
#amily2_chat_optimiser .rag-palace-entry-container {
    width: auto;
}

#amily2_chat_optimiser #rag_palace_panel {
    display: none;
}
 
#amily2_chat_optimiser .amily2-panel-visible {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* === 统一提示词编辑器按钮布局 === */
#amily2_chat_optimiser .prompt-editor-area {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

#amily2_chat_optimiser .prompt-editor-area textarea {
    flex: 1;
}



